<script type="text/javascript">
	$(function() {
		var redirect="";
		$(".deleteBoton").click(function() {
			redirect = $(this)[0].href;
			$("#deleteWindow").dialog('open');
			return false;
		})	
		 

		
		$("#deleteWindow").dialog({
			bgiframe: true,
			resizable: false,
			autoOpen: false,			
			height:140,
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				'Borrar': function() {
					$(this).dialog('close');
					location.href=redirect;
					return false;
					
				},
				Cancel: function() {
					$(this).dialog('close');
					return false;
					
				}
			}
		});
	});
	</script>


<div id="deleteWindow" style="display:none" title="<?php __('action_delete',true) ?>">
<p> <?php echo __('msg_user_delete'); ?></p>
</div>

 <div class="kt-g1">
		<div class=" kt-right">
	   		<ul class="lst-tabs">
	   			<li id="icon-user-new"><span class="icon"></span>  <?php echo $html->link(__('users_new',true),$ruta_admin.'/add');?> </li>
	   			<li id="icon-user-lst" class="active"><span class="icon"></span> <?php echo $html->link(__('users_list',true),$ruta_admin.'/');?> </li>
	  		</ul>	  
		</div>
</div>

<div class="kt-md kt-md-content">	   		 
		<div class="hd">
			 <h2><?php echo __('users_title_list'); ?> </h2>	
		</div>
		<div class="bd lst-form">
			<div class="searcher">
			 <?php  	 
				 echo $form->create("User", array('action' =>'search'));
	    		 echo $form->input("username", array('label' =>__('users_search',true)));
	   			 echo $form->end("Search");  
   			 ?>	
   			 
   			 <?php
				echo $paginator->counter(array(
				'format' => __('Total %count%, Pagina %page% de %pages%, numero de elementos %current%,  ( %start% de  %end% )',true)
				)); 
			?>
			</div>
		  
				<h3>Listado</h3>
				<table class="lst-info"> 
						<tr class="form-field"> 
							<th><?php echo __('id')?></th>
							<th><?php echo __('users_name')?></th>
							<th><?php echo __('email')?></th>
							<th><?php echo __('roles')?></th>
							<th><?php echo __('actions')?></th>
						</tr>
						
						<?php  
					
						if (count($users)>0)
						foreach ($users as $user){ ?>
						<tr class="form-field"> 
							<td><?php echo $user['User']['id']?></td>
							<td><?php echo $html->link($user['User']['username'], $ruta_admin."view/".$user['User']['id']); ?></td>
							<td><?php echo $user['User']['email']?></td>
							<td><?php echo $user['User']['role_id']?></td>
							<td>
							<?php echo $html->link(__('action_edit',true), $ruta_admin."edit/".$user['User']['id']); ?>
							<?php echo $html->link(__('action_delete',true), $ruta_admin."delete/".$user['User']['id'], array('class' => 'deleteBoton')); ?>
							</td>
						</tr>
						<?php } ?>
				</table>
			
			</div>
		
		<div class="ft"> 
			<p>	<?php echo $html->link(__('users_create_new',true), $ruta_admin."add/");?></p>
			<?php if ($paginator->next()!="" || $paginator->prev()!=""){?>
			<div class="kt-wg-paginator">
				<?php echo $paginator->prev('<< '.__('Previous Page', true), array(), null, array('class'=>'ant disabled'));?>
 					 	<?php echo $paginator->numbers();?>
				<?php echo $paginator->next(__('Next Page', true).' >>', array(), null, array('class'=>'next disabled'));?>
				</div>
			<?php } ?>
		</div>
</div>